<script setup lang="ts">
import { toLine } from '../../../utils'

let props = defineProps({
  // 显示图标
  icon: {
    type: String,
    default: 'Bell'
  },
  // 通知数量
  value: {
    type: [String, Number],
    default: ''
  },
  // 最大值
  max: {
    type: Number
  },
  // 是否显示小圆点
  isDot: {
    type: Boolean,
    default: false
  }
})
</script>

<template>
  <el-popover placement="bottom" :width="400" trigger="click">
    <template #default>
      <slot></slot>
    </template>
    <template #reference>
      <el-badge
        :value="props.value"
        :max="props.max"
        :is-dot="props.isDot"
        style="cursor: pointer"
      >
        <component :is="`el-icon-${toLine(props.icon)}`"></component>
      </el-badge>
    </template>
  </el-popover>
</template>

<style lang="scss" scoped>
svg {
  width: 1em;
  height: 1em;
}
</style>
